# include"Bspline.h"
# include<iostream>
# include<fstream>

using namespace std;

# define Num 401

// 定义函数 f(x)
class Fun : public Function
{
public:
    double operator() (const double & _x) const
    {
        return (1.0 / (1.0 + _x * _x));
    }
};

// 测试程序
int main()
{
    vector<double> point32, point21;
    for(int i = 1; i <= 11; i++)
        point32.push_back(-6.0 + i);
    for(int i = 1; i <= 10; i++)
        point21.push_back(i - 5.5);
    
    Fun fun;
    ofstream fout;
    fout.open("data/ProC.txt", ios::out);

    double eps1 = 10.0 / 400;
    Bspline Car32(S32Car, point32, fun);
    for (int i = 0; i < Num; i++)
    {
        fout << Car32.solve(-5.0 + i * eps1) << " ";
    }
    fout << endl;

    double eps2 = 10.0 / 400;
    Bspline Car21(S21Car, point21, fun);
    for (int i = 0; i < Num; i++)
    {
        fout << Car21.solve(-5.0 + i * eps2) << " ";
    }
    fout << endl;
    fout.close();

    cout << "Finish ploting." << endl;

    return 0;
}